function varitest(time,Y,casenum)

load('orthbase');

switch casenum
    case 1
        exactvar=time;
    case 2
        exactvar=time/2-1/4*sin(2*time);
    case 3
        exactvar=time/2-1/20*sin(10*time);
    case 4
        exactvar=time/2-1/120*sin(60*time);
    case 5
        exactvar=zeros(51,1);
        myfun=@(s) sin(exp(5*s)).^2;
        for ii=2:51
            exactvar(ii)=quadl(myfun,0,time(ii));
        end
end

hold on
tmp=zeros(size(Y(:,1)));
for ii=1:size(Y,2)
    %tmp=tmp+Y(:,ii).*Y(:,ii);
    tmp=tmp+Y(:,ii);
end
plot(time,tmp,'r-');
time=linspace(0,0.5,51);
plot(time,exactvar);
title('Variance')
legend('wce var','exact var');